<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>欢乐谷</title>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <link rel="stylesheet" href="/new/layui/css/layui.css">
    <link rel="stylesheet" href="/new/css/entertain/x-admin.css" media="all">
    <script type="text/javascript" src="/new/js/entertain/xadmin.js"></script>
</head>
<body>
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="x-red">*</span>主题名</label>
        <div class="layui-input-inline">
            <input type="text" name="entertainmentName" required lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label"><span class="x-red">*</span>主题介绍</label>
        <div class="layui-input-inline">
            <textarea name="entertainmentContent" required lay-verify="required" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">保存</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script src="/layui/layui.js" charset="utf-8">
</script>
<script src="/js/entertain/x-layui.js" charset="utf-8">
</script>
<script>
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data){
            console.log(JSON.stringify(data.field));
            $.ajax({
                url : "/manager/adde",
                type : "post",
                contentType: "application/json",
                data : JSON.stringify(data.field),
                success : function (data) {
                    if (data.status == 200) {
                        layer.alert(data.message,function () {
                            //关闭弹出窗，刷新list页面
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.location.reload();
                            parent.layer.close(index);
                        });
                        //parent.window.location.replace("/day02/list")
                    } else {
                        layer.alert(data.message);
                    }
                },
                error : function (data) {
                    layer.alert(data.responseText);
                }
            });
            return false;
        });
    });
</script>
</body>
</html>